import React, {useEffect, useState} from "react";
import { Pagination } from 'antd';
import request from "@/utils/ajax/request";
const Personal = () =>{
    const [current, setCurrent] = useState(parseInt(window.location.hash.slice(6), 0) || 1);
    const [total, setTotal] = useState(0);
    const [list, setList] = useState([])
    const onChange = (page) => {
        getListData(page)
        setCurrent(page);
    };
    //获取订单列表
    const getListData = (current) =>{
        let Url = `${window.base.config.baseUrl}home/reviews/index?gid=704407997&token=1ec949a15fb709370f&page=${current}`
        request(Url,'get').then((res)=>{
            if (res.code === 200){
                setTotal(res.pageinfo.total);
                setList(res.data);
            }
        })
    }
    useEffect(()=>{
        getListData(current)
        window.location.hash = `page=${current}`;
    },[current])
    return(
        <div>
            <br />
            {
                list && list.length>0 && list.map((item, index)=>{
                    return(
                        <div key={index}>{item.content}</div>
                    )
                })
            }
            <Pagination  current={current} onChange={onChange} total={total} />
        </div>
    )
}
export default Personal;